#include "PEClientPCH.h"


using namespace Memory;
using namespace Utility;


LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam);
HWND CreateMainWindow(HINSTANCE hInstance,int iCmdShow);
bool ProcessMessages(void);
void GetWindowParams(bool& bIsFullscreen, DWORD& dwExStyle, DWORD& dwStyle, int& nWidth, int& nHeight, int& nOffsetX, int& nOffsetY);



int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	//_CrtSetBreakAlloc( 1175377 );

	MM_MemoryManager::Init();

	UT_LogStream* pkLogStream = MM_NEW UT_LogStreamFileBase(DD_TEXT("xxxx"));
	
	while (ProcessMessages())
	{
		
	}

	MM_MemoryManager::UnInit();	


	return 0;
}

bool ProcessMessages(void)
{
	MSG message;
	BOOL result = TRUE;

	// Peek at all messages, not just the ones for the main window. If this is not done 
	// the application will be listed as 'not responding' when the main window does not
	// have focus, as it will not receive messages.
	while (result == TRUE)
	{
		// Use PeekMessage() so we can use idle time to render the scene. 
		result = PeekMessage(&message, NULL, 0U, 0U, PM_REMOVE);

		if (result)
		{
			TranslateMessage(&message);
			DispatchMessage(&message);

			if (message.message == WM_QUIT)
			{
				return false;
			}
		}
	}

	return true;
}
